package com.four.controller;

import com.four.entity.News;
import com.four.service.NewsService;
import com.four.vo.NewsSearchForm;
import com.four.vo.Result;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: WangPeng
 * @createTime: 2022/10/17 20:35
 * @description:
 * @version: v1.0
 */
@RestController
@RequestMapping("/news")
public class NewsController {

    @Autowired
    private NewsService newsService;

    @RequestMapping("/all9And1")
    public Result all9And1(@RequestParam(defaultValue = "1")Integer currentPage,
                      @RequestParam(defaultValue = "5")Integer pageSize,
                      @RequestBody NewsSearchForm newsSearchForm){
        return newsService.selectAllAddnews9And1(currentPage,pageSize,newsSearchForm);
    }

    @RequestMapping("/all9")
    public Result all9(@RequestParam(defaultValue = "1")Integer currentPage,
                      @RequestParam(defaultValue = "5")Integer pageSize,
                      @RequestBody NewsSearchForm newsSearchForm){
        return newsService.selectAllAddnews9(currentPage,pageSize,newsSearchForm);
    }

    @RequestMapping("/all1")
    public Result all1(@RequestParam(defaultValue = "1")Integer currentPage,
                      @RequestParam(defaultValue = "5")Integer pageSize,
                      @RequestBody NewsSearchForm newsSearchForm){
        return newsService.selectAllAddnews1(currentPage,pageSize,newsSearchForm);
    }

    @RequestMapping("/deleteById")
    public Result del(Integer id){
        return newsService.deleteById(id);
    }

    @RequestMapping("/add")
    public Result addNews(News news){
        return newsService.addNews(news);
    }

    @RequestMapping("/passNews")
    public Result passNews(@RequestBody News news){
        return newsService.passAllnews(news);
    }

    @RequestMapping("/putAwayNews")
    public Result putAwayNews(@RequestBody News news){
        return newsService.putAwayNews(news);
    }
}
